package com.pokerpro.Scanner;

import static com.pokerpro.Constant.Colors.*;
import static com.pokerpro.Constant.Positions.*;
import static com.pokerpro.support.Log.log;

import java.awt.Color;
import java.awt.Point;
import java.awt.Robot;
import java.util.List;

import com.pokerpro.interfaces.TableEvents;
import com.pokerpro.support.BaseElement;

public class ActionScanner extends BaseElement implements Runnable {
	
	TableEvents ev;
	private Point buttonLeft;
	private Point buttonMiddle;
	private Point buttonRight;
	
	public ActionScanner(Robot pRobot, List<Point> pPoints, TableEvents ev) {
		super(pRobot);
		buttonLeft = pPoints.get(0);
		buttonLeft = pPoints.get(1);
		buttonLeft = pPoints.get(2);
		this.ev = ev;
	}

	public void run() {
		boolean b = false;
		log("Action Scanner runs!");
		while (true) {
			Color acutalColor = getPixelCol(TABLE1_ACTION_BUTTON_LEFT);
			if (acutalColor.equals(COLOR_ACTION_BUTTON_OFF) && b==false) {
				log("Action required");
				ev.actionRequired();
				b=true;
			}
			else if (!acutalColor.equals(COLOR_ACTION_BUTTON_OFF)){
				b=false;
			}
		}
	}
}
